package com.cjbdi.dao;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.cjbdi.entity.UserSubscribe;

@Repository
public interface UserSubscribeRepository extends JpaRepository<UserSubscribe, Long> {
	
	@Query(value = "select * from user_subscribe where id = :id", nativeQuery = true)
	List<UserSubscribe> getSubscribeByid(@Param("id") int id);
    
    @Query(value = "select * from user_subscribe where case when :status!=''then status = :status else 1=1 end and case when :fymc!='' then fymc like '%'||:fymc||'%' else 1=1 end and case when :sfunction!=''then sfunction = :sfunction else 1=1 end" , nativeQuery = true)
    Page<UserSubscribe> getPageByParam(@Param("status") String status,@Param("fymc") String fymc,@Param("sfunction") String sfunction,Pageable pageable);
    
    
}
